<?php 
class Tusergrouprelation extends AppModel {


	var $name = 'Tusergrouprelation';
	var $useTable = 'tuser_group_relation';
	var $primaryKey = "id";
	/**
     * get group users by groupid
     *
     * @param int $gid	groupid
     * @return array
     */
	function getGroupUsers($gid = NULL) {
		$result = array();
		if (NULL == $gid) {
			return $result;
		}
		$rs = $this->findAll("f_gid='$gid'");
		if (0 == count($rs)) {
			return $result;
		}
		foreach ($rs as $value) {
			$result[] = $value['Tusergrouprelation']['f_uid'];
		}
		return $result;
	}
	/**
	 * get user in witch groupids
	 *
	 * @param int $uid	userid
	 * @return array
	 */
	function getUserGroups($uid = NULL)
	{
		$result = array();
		if (NULL == $uid) {
			return $result;
		}
		$rs = $this->findAll("f_uid='$uid'");
		if (0 == count($rs)) {
			return $result;
		}
		foreach ($rs as $value) {
			$result[] = $value['Tusergrouprelation']['f_gid'];
		}
		return $result;
	}


}
?>
